EMT Practice Test

1. Question Content...


Question List

Question1: An employee works forty or more hours in a pay period. Assuming that overtime is paid for hours greater than 40 hours at a rate of time and a half, which EVAL statement will calculate the gross pay (GPay)?

Question2: The following code segment is part of an existing program:
C*0N01Factor1+++++++Opcode(E)+Factor2+++++++Result+++++++Len++D+HiLoEq
C If C = D
C Eval *IN50 = *off
C EndIf
Which of the following produces equivalent results under ALL possible conditions?

Question3: Given the following code segment (Note that the field "Hours" is assumed to be defined in a database used by the program):
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++++++++++
+
D MonHrs DS D AverageHrs 4 2
D Employees 2 0
D TotalHours 7 2
C Eval Employees += 1
C Eval TotalHours = TotalHours + Hours
C Eval AverageHrs = TotalHours / Employees
An error occurs when executing this code. Which of the following would correct the error?

Question4: A Service Program needs to be created without using Binder Language
. Module A contains a procedure named A
. Module B contains a procedure named B
.Module C contains procedures named C1 and C2.
All four of the procedures are to have their names exported. Which of the following commands will accomplish this?

Question5: Given the following display file DDS example:
AAN01N02N03T.Name++++++RLen++TDpBLinPosFunctions++++++++
A SFLRCD 4S 0H SFLRCDNBR(CURSOR)
What is the use of the variable SFLRCD?

Question6: The task is to create a service program from the RPG modules A and B. Module A contains a main procedure named A. Module B is a NOMAIN module containing the subprocedures X and Y. Which of the following binder language source examples could be used to create the service program?

Question7: Which of the following code segments will fill FLD1 with lower-case x characters?

Question8: Given the following DDS for Physical file CATFILE:
A R CATREC
A CATCOD 5S 0
A CATDES 20A
And the following code for Pgm1:
FCatFile UF A E K DISK
D CategoryRec E DS ExtName(CatFile)
C Read(E) Emp
And the following code for Pgm2:
FCatFile UF A E K DISK
C Read(E) Emp
What are the attributes of the CatCod field in both programs?

Question9: File CustFile contains a record format CustR, with a single key field CustNumber. Given the following code segment:
FFilename++IPEASF.....L.....A.Device+.Keywords+++++++++++++++++++++++++ FCustFile if e k disk DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++++++++++
+
D Cust# S 5 0
In /Free format, which of the following CHAIN operations will retrieve the customer record for the Customer number in field Cust#?

Question10: An RPG program encounters an error. The programmer tries to match the statement number reported by the error message with the source and discovers that statement is a comment. Clearly this is not the statement in error. Which of the following can be coded in the H-Spec to ensure that run time errors reference statement numbers that correspond to those in the source member?

Question11: Given the following code segment:
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++
D GetBalDue PR
D Balance 11P 2
D CustNo 5S 0
D Qty 7P 0
D Amount 5P 2
D Balance S 11P 2
D CustNo S 5S 0
D OrdQty S 7P 0
D Amt S 5P 2
Which of the following contains correct syntax?

Question12: APP01 is a program consisting of modules A and B which will call procedures X and Y from a Service Program named UTILITIES. Which of the following Binding Directories contains the information required to successfully create APP01 using the following command?
CRTPGM PGM(APP01) MODULE(A) BNDDIR(MYBNDDIR) OPTION(*NODUPPROC)

Question13: Which of the following RPG IV operations will output a display file format on the screen and continue processing without waiting for a user response?

Question14: While stepping through a program in debug mode, a programmer discovers that after a CHAIN operation, it is necessary to press the step key multiple times before reaching the next executable instruction. Which of the following H specification keywords can be used to avoid generating these additional breakpoints?

Question15: Given the following field definitions, if field mmddyy contains a date in MDY format, what is the correct syntax to populate DateFld with the content of mmddyy?
D mmddyy S 6A
D DateFld S D Inz(D'2003-06-27') DatFmt(*ISO)

Question16: Given the following code segment:
/FREE
DoU %Eof(File1);
Read File1;
*IN90 = %EOF; *IN90 =
*OFF; EndDo;
/END-FREE
How many times will the code inside of the DoU loop be run if File1 contains no records?

Question17: Given the following code segment:
0001.00 D DateField S D DATFMT(*ISO)
0002.00 D CharField S 6A INZ('040696')
0003.00 C *MDY MOVE CharField DateField
This code will not compile. Which of the following changes will allow a successful compile?

Question18: Given the following code segment:
FFilename++IPEASF.....L.....A.Device+.Keywords++++++++++++++++++++++++
FCustMast IF E K Disk UsrOpn
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result+++++++Len++D+HiLoEq
C CustKey ReadE(E) CustMast
Which of the following will cause %Error to be set on when the Read is run?

Question19: Procedure PROC1 in a Service Program must be called passing to it a 5 position field.
Which of the following code segments will accomplish this task?

Question20: Given the following RPG IV file specifications:
FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords
FFILE1 UF A E DISK
FFILE2 UF E A DISK
FFILE3 UF E DISK
FFILE4 UF E DISK UPDOPT(*ADD)
Which file will allow the WRITE operation to be used?

Question21: Which of the following can be achieved by passing parameters by Value instead of by Reference?

Question22: Review the following sample subfile:
+----------------------+
| Option Data |
| ------ --------- |
| | | Record 1 |
| | | Record 2 |
| |X| Record 3 |
| | | Record 4 |
+----------------------+
The SFLNXTCHG keyword was inactive when Record 1 was written and active when each subsequent subfile record was written. The operator has entered the "X" in the option field for Record 3. Which subfile record will be read when the next READC operation is performed on the subfile?

Question23: Given the following code segment:
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++
D Arra s 3s 0 DIM(10)
D Index s 2s 0 Inz(0)
/FREE
For Index = 1 to %Elem(Arra);
Arra(Index) = 2 * Index;
EndFor; /END-FREE
What is the value of field Index after the code is run?

Question24: Which of the following represents the sequence of embedded SQL statements required to extract multiple records based on criteria that are not known at compile time?

Question25: An RPG source member containing subprocedures, will be compiled using the CRTBNDRPG command. What value must be specified for the Default Activation Group parameter?

Question26: Which of the following RPG constructs can be used to return the user ID of the user running the program?

Question27: In the following code sample, file CUSSALES contains a record format CUSSALESR, with unique key fields CSCONO, CSCSNO and CSYEAR.

Assuming the READE operation is successful, which record is retrieved?

Question28: Which of the following code segments shows the correct use of the externally described printer file PRT1 containing record format FMT1?

Question29: What is the purpose of a procedure prototype in a calling program?

Question30: In the following segment, if file CUSMS contains a field CMCSNM, how would that field be referred to as a subfield of the 3rd element of data structure array CUSTINFO?
FFilename++IPEASF.....L.....A.Device+.Keywords++++++++++++++++
fcusms if e k disk rename(cusmsr:custmastr)
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++
d custinfo
ds qualified dim(4)
d salesman 3 0
d custrecd likerec(custmastr)

Question31: Given the following code segment:
....DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++
001 D Myproc PI 3
002 D P1 D
003 D P2 5A
004 D P3 D
What is the purpose of the value "3" specified on line 1?

Question32: Given the following code segment:
d CusInfo ds dim(10) qualified
d CusNum 5 0
d AmtDue 7 2
d OrdYTD 7 2
d OrdPrv 7 2
How would the AmtDue subfield for the 5th element of the CusInfo array be referenced?

Question33: Given the following code segment:
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++
D DS
D Name 40A INZ('IBM Corporation')
D Part1 15 overlay(Name)
D Part2 overlay(Name:*next) like(Part1)
What are the characteristics of the Part2 field?

Question34: In an RPG program, which of the following is used as an alternative to an *ENTRY PLIST?

Question35: CL program PGMA, issues an OPNQRYF statement and then calls RPG program PGMB to process the results of the OPNQRYF. This combination was working until PGMB was recreated to run in a different Activation Group from PGMA. Now PGMB does not see the results of the OPNQRYF statement. Which of the following parameters added to the OPNQRYF statement would allow PGMB to see the correct OPNQRYF results again?

Question36: An API's documentation indicates a required parameter of type BINARY, length 4. How should this parameter be coded in a prototype?

Question37: Given the following code segment:
H DATFMT(*YMD)
D Date1 S D INZ(D'25/10/30')
D Date2 S D DATFMT(*MDY-) INZ(D'25/10/30')
D Date3 S D DATFMT(*USA ) INZ(D'25/10/30') D
Date4 S D DATFMT(*ISO ) INZ(D'25/10/30')
After initialization which of the following is correct?

Question38: Given the following code segment:
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++++++++++
+++++
D Date6N S 6 0
D DateISO S D Inz(D'2004-10-25') Datfmt(*ISO)
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq...
C *mdy Move DateISO Date6N
Which of the following statements is the /Free form equivalent to the move operation?

Question39: A program needs to concatenate the 3 numeric fields shown below such that Phone# contains a string in the format aaabbbcccc, where aaa is the AreaCode field, bbb is the PhPrefix field and cccc is the PhNbr field. All positions of Phone# must be filled with digits.
D AreaCode S 3 0
D PhPrefix S 3 0
D PhNbr S 4 0
D Phone# S 10A
Which of the following code segments would correctly accomplish this task in all circumstances?

Question40: Given the following code segment:
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++++++++++++
++++
D AmtChar S 10 Inz(' 123456789')
D TaxPct S 3 3 Inz(.055)
D Tax S 8 2
C Eval Tax = %Dec(AmtChar: 10: 2) * TaxPct
If the Eval statement were to be run, what error would occur?

Question41: Service Program UTILA is a utility service program that once called MUST remain active for the life of the job. Which of the following commands will create the service program so that once it has been initiated all further calls to its procedures will use the same instance?

Question42: Given the following code segment:
d MyPgm pr extpgm('MYPGM')
d CustName 20
Which of the following keywords, if added to parameter CustName, would allow an expression to be passed?

Question43: Given the following code segment:
d GetAcctBal pr 11 2
d AcctNum 7 0
d Year 4s 0
d Period 2s 0
The identifiers AcctNum, Year and Period are used for what purpose?

Question44: Given the following code segment:
HKeywords++++++++++++++++++++++++++++++++++++++++++
H DatFmt(*YMD)
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++
D Date1 s
D D Date2 s 7P 0 INZ(90895)
CL0N01Factor1+++++++Opcode(E)+Extended-
Factor2++++++++++++++++++++++++++++++++
C Eval Date1 = %Date(Date2: *MDY)
What is the value of the field Date1 after the EVAL operation is performed?